package com.huawei.bitfun.bean;

import com.huawei.deveco.projectmodel.ohos.model.ModuleModel;

import java.nio.file.Paths;
import java.util.Objects;

public class DocumentBean {
    private String pass;
    private String name;
    private String function;
    private DebugLocBean debugLoc;
    private ModuleModel moduleModel;

    public String getPass() {
        return pass;
    }

    public DebugLocBean getDebugLoc() {
        return debugLoc;
    }

    public String getName() {
        return name;
    }

    public ModuleModel getModuleModel() {
        return moduleModel;
    }

    public String getFunction() {
        return function;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setFunction(String function) {
        this.function = function;
    }

    public void setDebugLoc(DebugLocBean debugLoc) {
        this.debugLoc = debugLoc;
    }

    public void setModuleModel(ModuleModel moduleModel) {
        this.moduleModel = moduleModel;
    }

    public Integer getLine() {
        return this.getDebugLoc().getLine();
    }

    public Integer getColumn() {
        return this.getDebugLoc().getColumn();
    }

    public String getFile() {
        return Paths.get(this.getModuleModel().getModulePath(), this.getDebugLoc().getFile()).toString()
            .replaceAll("\\\\", "/");
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        if (object == null || getClass() != object.getClass()) {
            return false;
        }
        DocumentBean that = (DocumentBean) object;
        return Objects.equals(pass, that.pass) && Objects.equals(name, that.name) && Objects.equals(debugLoc, that.debugLoc);
    }

    @Override
    public int hashCode() {
        return Objects.hash(pass, name, debugLoc);
    }
}